import { DropdownItem, DropdownMenu } from '@antmjs/vantui'

import { useState } from 'react'
import { getMemberType } from '../api'
import useRequest from '../../../common/hooks/useRequest'

const MemberSelect = ({ onChange, style }) => {
	const [innerValue, setInnerValue] = useState('')

	const { data } = useRequest(getMemberType, {}, [], data => {
		setInnerValue(data[0].value)
	})

	const handleTypeChange = value => {
		setInnerValue(value)
		onChange && onChange(value)
	}

	return (
		<DropdownMenu style={style}>
			<DropdownItem
				options={data}
				value={innerValue}
				onChange={handleTypeChange}
			/>
		</DropdownMenu>
	)
}
export default MemberSelect
